//
// Created by Asus on 2025/6/2.
//

#include <iostream>
#include <list>
#include <string>
using namespace std;

class Person {
public:
    Person(string name, int age , int height) {
        m_Name = name;
        m_Age = age;
        m_Height = height;
    }
public:
    string m_Name;  //姓名
    int m_Age;      //年龄
    int m_Height;   //身高
};

bool ComparePerson(Person &p1, Person &p2) {
    if (p1.m_Age == p2.m_Age) {
        return p1.m_Height  > p2.m_Height;
    } else {
        return p1.m_Age < p2.m_Age;
    }
}

int main(int argc, char *argv[]) {
    list<Person> L;
    L.push_back(Person("John", 2018, 0));
    L.push_back(Person("John", 2018, 1));
    L.push_back(Person("John", 2038, 2));
    L.push_back(Person("John", 2028, 3));
    L.push_back(Person("John", 2017, 4));

    for (list<Person>::iterator it = L.begin(); it != L.end(); it++) {
        cout << "姓名： " << it->m_Name << " 年龄： " << it->m_Age
              << " 身高： " << it->m_Height << endl;
    }

    cout << "---------------------------------" << endl;
    L.sort(ComparePerson); //排序

    for (list<Person>::iterator it = L.begin(); it != L.end(); it++) {
        cout << "姓名： " << it->m_Name << " 年龄： " << it->m_Age
              << " 身高： " << it->m_Height << endl;
    }
    return 0;
}

